package com.ruoyi.web.controller.cat;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.cat.domain.AdGiftClassify1;
import com.ruoyi.cat.domain.AdGiftClassify2;
import com.ruoyi.cat.service.IAdGiftClassify2Service;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分类 小类Controller
 * 
 * @author ruoyi
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/system/classify2")
public class AdGiftClassify2Controller extends BaseController
{
    @Autowired
    private IAdGiftClassify2Service adGiftClassify2Service;

    /**
     * 查询分类 小类列表
     */
  //  @PreAuthorize("@ss.hasPermi('system:classify2:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdGiftClassify2 adGiftClassify2)
    {
        startPage();
        List<AdGiftClassify2> list = adGiftClassify2Service.selectAdGiftClassify2List(adGiftClassify2);
        return getDataTable(list);
    }

    @GetMapping("/getClassifyData2")
    public AjaxResult getClassifyData1(AdGiftClassify2 adGiftClassify2)
    {
        List<AdGiftClassify2> list = adGiftClassify2Service.selectAdGiftClassify2List(adGiftClassify2);
        return success(list);
    }

    /**
     * 导出分类 小类列表
     */
 //   @PreAuthorize("@ss.hasPermi('system:classify2:export')")
    @Log(title = "分类 小类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdGiftClassify2 adGiftClassify2)
    {
        List<AdGiftClassify2> list = adGiftClassify2Service.selectAdGiftClassify2List(adGiftClassify2);
        ExcelUtil<AdGiftClassify2> util = new ExcelUtil<AdGiftClassify2>(AdGiftClassify2.class);
        util.exportExcel(response, list, "分类 小类数据");
    }

    /**
     * 获取分类 小类详细信息
     */
 //   @PreAuthorize("@ss.hasPermi('system:classify2:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(adGiftClassify2Service.selectAdGiftClassify2ById(id));
    }

    /**
     * 新增分类 小类
     */
  //  @PreAuthorize("@ss.hasPermi('system:classify2:add')")
    @Log(title = "分类 小类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdGiftClassify2 adGiftClassify2)
    {
        return toAjax(adGiftClassify2Service.insertAdGiftClassify2(adGiftClassify2));
    }

    /**
     * 修改分类 小类
     */
   // @PreAuthorize("@ss.hasPermi('system:classify2:edit')")
    @Log(title = "分类 小类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdGiftClassify2 adGiftClassify2)
    {
        return toAjax(adGiftClassify2Service.updateAdGiftClassify2(adGiftClassify2));
    }

    /**
     * 删除分类 小类
     */
  //  @PreAuthorize("@ss.hasPermi('system:classify2:remove')")
    @Log(title = "分类 小类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adGiftClassify2Service.deleteAdGiftClassify2ByIds(ids));
    }
}
